package com.hainingtong.user.dto;

import com.fasterxml.jackson.annotation.JsonIgnore;
import com.hainingtong.user.dto.group.DefaultGroup;
import com.hainingtong.user.dto.group.PhoneCodeGroup;
import com.hainingtong.user.dto.group.PhonePasswordGroup;
import com.hainingtong.user.dto.group.UsernamePasswordGroup;
import com.hainingtong.user.shiro.token.LoginType;
import io.swagger.annotations.ApiModel;
import io.swagger.annotations.ApiModelProperty;
import lombok.Data;
import org.hibernate.validator.constraints.Length;

import javax.validation.constraints.NotNull;
import javax.validation.constraints.Pattern;

@ApiModel("账号密码登陆")
@Data
public class LoginUserDto {
    @ApiModelProperty("登陆账号")
    @NotNull(groups = DefaultGroup.class, message = "账号不能为空")
    @Length(groups = UsernamePasswordGroup.class, min = 4, max = 20, message = "账号只能包含4~20个数字字母下划线")
    @Pattern(groups = {PhonePasswordGroup.class, PhoneCodeGroup.class}, regexp = "1[3-9]\\d{9}", message = "手机号格式不正确")
    String principal;

    @ApiModelProperty("登陆密码")
    @NotNull(groups = {UsernamePasswordGroup.class, PhonePasswordGroup.class}, message = "密码不能为空")
    @Length(groups = {UsernamePasswordGroup.class, PhonePasswordGroup.class}, min = 6, max = 100, message = "密码长度6~50个字符")
    String credentials;

    @JsonIgnore
    String type;
}
